const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
function judge(hh, mm) {
    // 判断给定的时间是否为回文数
    let list = []
    if( hh < 10 ){
        list = list.concat(['0', hh.toString()]);
    }else {
        list = list.concat(hh.toString().split(''));
    }
    if( mm < 10 ){
        list = list.concat(['0', mm.toString()]);
    }else {
        list = list.concat(mm.toString().split(''));
    }
    // console.log(list)
    return list[0] === list[3] && list[1] === list[2];
}

void async function () {
    // Write your code here
    while(line = await readline()){
        let tokens = line.split(":").map(Number);
        let hours = parseInt(tokens[0]);
        let minutes = parseInt(tokens[1]);
        let res = 0;    // 最终渡过分钟
        // console.log(hours, minutes)
        while(true) {
            if(judge(hours, minutes)){
                console.log(hours, minutes)
                console.log(res)
                break;
            }
            res++;
            minutes++;
            if(minutes === 60) {
                minutes = 0;
                hours++;
            }
            if(hours === 24) {
                hours = 0;
            }
        }
    }
}()